//
//  PAAddCardView.m
//  PAMobileWallet
//
//  Created by Pay_SMP002 on 13-7-4.
//  Copyright (c) 2013年 平安付. All rights reserved.
//

#import "PAAddCardView.h"
#import "PAAddCardViewController.h"
#import "UIColor+Extend.h"

@implementation PAAddCardView
@synthesize cardtfBgImage;
@synthesize cardNumTF;
@synthesize nextButton;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code

        CGSize size = frame.size;
//        CGFloat x, y, w, h;
//        w = 100;
//        h = 30;
//        x = (size.width - w) / 2;
//        y = 150;

        nextButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
//        nextButton.frame = CGRectMake((size.width-TEXTFIELD_SIZE.width)/2, 44 + 20 + TEXTFIELD_SIZE.height + 5 + 30 + 10, TEXTFIELD_SIZE.width, TEXTFIELD_SIZE.height);
        nextButton.frame = CGRectMake((size.width-TEXTFIELD_SIZE.width)/2, 20+44 + 20 + TEXTFIELD_SIZE.height + 5 + 30 + 10, TEXTFIELD_SIZE.width, TEXTFIELD_SIZE.height);
        [nextButton setTitle:@"确定" forState:UIControlStateNormal];
        [nextButton setBackgroundImage:[UIImage imageNamed:@"button_B1.png"] forState:UIControlStateNormal];
        nextButton.titleLabel.textColor = ENABLE_COLOR;
        nextButton.titleLabel.font = [UIFont systemFontOfSize:18.0];
        [nextButton addTarget:self action:@selector(buttonActive:) forControlEvents:UIControlEventTouchUpInside];
        nextButton.enabled = NO;
        nextButton.tag = 0;
        [self addSubview:nextButton];
        
        cardtfBgImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"textbox2.png"]];
        cardtfBgImage.frame = CGRectMake((size.width-TEXTFIELD_SIZE.width)/2, 44 + 30, TEXTFIELD_SIZE.width, TEXTFIELD_SIZE.height - 10);
        cardtfBgImage.backgroundColor = [UIColor clearColor];
        [self addSubview:cardtfBgImage];

        cardNumTF = [[UITextField alloc] initWithFrame:CGRectMake((size.width-TEXTFIELD_SIZE.width)/2+10, 44 + 30, TEXTFIELD_SIZE.width-10, TEXTFIELD_SIZE.height - 10)];
        [cardNumTF setBorderStyle:UITextBorderStyleNone]; //外框类型
        cardNumTF.keyboardType = UIKeyboardTypeNumberPad;
        cardNumTF.placeholder = @"请输入卡号"; //默认显示的字
        cardNumTF.secureTextEntry = NO; //密码
        cardNumTF.contentHorizontalAlignment = NSTextAlignmentCenter;
        cardNumTF.contentVerticalAlignment = NSTextAlignmentLeft;
        cardNumTF.backgroundColor = [UIColor clearColor];
        cardNumTF.clearButtonMode = UITextFieldViewModeWhileEditing; //编辑时会出现个修改X
        [self addSubview:cardNumTF];
        
//        UILabel * markLable = [[UILabel alloc] initWithFrame:CGRectMake((size.width-TEXTFIELD_SIZE.width)/2, 44 + 20 + TEXTFIELD_SIZE.height + 5, TEXTFIELD_SIZE.width, TEXTFIELD_SIZE.height - 20)];
        UILabel * markLable = [[UILabel alloc] initWithFrame:CGRectMake((size.width-TEXTFIELD_SIZE.width)/2, 44 + 20 + TEXTFIELD_SIZE.height + 5, TEXTFIELD_SIZE.width, 60)];

        markLable.text = @"目前支持:中国邮政储蓄银行 、中国工商银行、中国农业银行、中国建设银行、中国招商银行、兴业银行、广东发展银行、民生银行、光大银行、中信银行";
        markLable.numberOfLines = 0;
        markLable.backgroundColor = [UIColor clearColor];
        markLable.textAlignment = NSTextAlignmentLeft;
        [markLable setTextColor:[UIColor colorWithHexString:@"#ACB086"]];
        [markLable setFont:[UIFont systemFontOfSize:12.0]];
        [self addSubview:markLable];

    }
    return self;
}

-(void)buttonActive:(id)sender
{
    [self.parentController testNext:sender];
}


#pragma mark - UITextFieldDelegate  methods

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    
    return YES;
}

- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    cardtfBgImage.image = [UIImage imageNamed:@"textbox2.png"];
}

- (void)textFieldDidEndEditing:(UITextField *)textField
{
    
}

@end
